<div class="layui-container fly-marginTop fly-user-main">
    <!-- 会员中心的菜单 -->
    <ul class="layui-nav layui-nav-tree layui-inline" id="nav" lay-filter="user">
      <li class="layui-nav-item">
        <a href="{:url('home/user/index')}">
          <i class="layui-icon">&#xe609;</i>
          我的主页
        </a>
      </li>
      <li class="layui-nav-item">
        <a href="{:url('home/user/profile')}">
          <i class="layui-icon">&#xe620;</i>
          基本设置
        </a>
      </li>
      <li class="layui-nav-item">
        <a href="{:url('home/post/index')}">
          <i class="layui-icon">&#xe6fb;</i>
          我的帖子
        </a>
      </li>
      <li class="layui-nav-item layui-this">
        <a href="{:url('home/post/collect')}">
          <i class="layui-icon">&#xe83c;</i>
          我的收藏
        </a>
      </li>
      <li class="layui-nav-item">
        <a href="{:url('home/user/record')}">
          <i class="layui-icon">&#xe702;</i>
          积分消费记录
        </a>
      </li>
    </ul>
  
    <div class="site-tree-mobile layui-hide">
      <i class="layui-icon">&#xe602;</i>
    </div>
    <div class="site-mobile-shade"></div>
    
    <div class="site-tree-mobile layui-hide">
      <i class="layui-icon">&#xe602;</i>
    </div>
    <div class="site-mobile-shade"></div>
    
    
    <div class="fly-panel fly-panel-user" pad20>
      <div class="layui-tab layui-tab-brief" lay-filter="user">
        <ul class="layui-tab-title" id="LAY_mine">
          <li data-type="mine-jie" lay-id="index" class="layui-this">
            我收藏的帖（<span>{$count}</span>）
          </li>
        </ul>
        <div class="layui-tab-content" style="padding: 20px 0;">
          <div class="layui-tab-item layui-show">
            <ul class="mine-view jie-row">
              {foreach $collectlist as $item}
                <li>
                  <a class="jie-title" href="{:url('home/index/info',['postid'=>$item.post['id']])}" target="_blank">{$item.post.title}</a>
                  <i>{$item.createtime}</i>
                  <a class="mine-edit CollectDel" type="edit" data-postid="{$item.postid}" href="javascript:void(0)">取消收藏</a>
                  <em>{$item.post.visit_text}阅/{$item.post.comment}答</em>
                </li>
              {/foreach}
            </ul>
            <div id="LAY_page">
              {$pagestr}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

<script>
  layui.use('layer',function(){
    var layer=layui.layer
    var $=layui.jquery
    // 取消收藏
    $(".CollectDel").on('click', function(){
      var postid=$(this).data('postid')
        //发送异步请求
        $.ajax({
          url:`{:url('home/Post/uncollect')}`,
          type:'post',
          data:`postid=${postid}`,
          dataType:'json',
          success:function(success)
          {
            if(success.result)
            {
              //成功
              layer.msg(success.msg, {
                icon: 1,
                time: 2000 //2秒关闭（如果不配置，默认是3秒）
              }, function(){
                //直接刷新界面
                location.reload()
              })
            }else
            {
              //删除失败
              layer.msg(success.msg)
            }
          }
        })
    })
  })

</script>